package com.dmall.scf

import com.dmall.scf.action.kanban.{RegMoneyDistributionAction, SupplierCounterByTypeAction}
import com.dmall.scf.action.{SaleShareAction, SaleShareByDimensionAction}
import com.dmall.scf.demo.{SparkProdDemo, SparkReadHive}
import com.dmall.scf.utils.SparkUtils
import org.apache.spark.sql.SparkSession

/**
 * @descrption SparkMain入口
 * @author wangxuexing
 * @date 2019/12/22
 */
object SparkHiveToMysql {
  def main(args: Array[String]): Unit = {
    if(args == null || args.length == 0){
        throw new Exception("请指定Action！")
    }
    println(s"==================Starting....${args(0)}===========")
    val spark: SparkSession = SparkUtils.getEnv.spark
    args(0) match {
      case SaleShareAction.CLASS_NAME => SaleShareAction.execute(args, spark)
      case SparkProdDemo.CLASS_NAME => SparkProdDemo.execute(args)
      case SparkReadHive.CLASS_NAME => SparkReadHive.execute(args)
      case SaleShareByDimensionAction.CLASS_NAME => SaleShareByDimensionAction.execute(args, spark)
      case SupplierCounterByTypeAction.CLASS_NAME => SupplierCounterByTypeAction.execute(args, spark)
      case RegMoneyDistributionAction.CLASS_NAME => RegMoneyDistributionAction.execute(args, spark)
      case _ => throw new Exception(s"没有指定的Action：${args(0)}！")
    }
    println(s"==================End....${args(0)}===========")
    spark.stop()
  }
}
